#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

class segment_tree {
	using ll = long long;
	vector<ll> &arr;
	vector<ll> isum;
	vector<ll> imax;

	void up(int i)
	{
		isum[i] = isum[i << 1] + isum[i << 1 | 1];
		imax[i] = max(imax[i << 1], imax[i << 1 | 1]);
	}

	void build(int l, int r, int i)
	{
		if (l == r) {
			imax[i] = arr[l];
			isum[i] = arr[l];
		} else {
			int mid = (l + r) >> 1;
			build(l, mid, i << 1);
			build(mid + 1, r, i << 1 | 1);
                        up(i);
		}
	}

    public:
	void range_sqrt(int jobl, int jobr, int l, int r, int i)
	{
		if (l == r) {
                        arr[l] = sqrt(arr[l]);
			imax[i] = arr[l];
			isum[i] = arr[l];
			return;
		}

		if (imax[i] != 1) {
			int mid = (l + r) >> 1;
			if (jobl <= mid) {
				range_sqrt(jobl, jobr, l, mid, i << 1);
			}
			if (mid < jobr) {
				range_sqrt(jobl, jobr, mid + 1, r, i << 1 | 1);
			}
			up(i);
		}
	}

	ll query(int jobl, int jobr, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			return isum[i];
		}

		int mid = (l + r) >> 1;
		ll ans = 0;
		if (jobl <= mid) {
			ans += query(jobl, jobr, l, mid, i << 1);
		}
		if (mid < jobr) {
			ans += query(jobl, jobr, mid + 1, r, i << 1 | 1);
		}

		return ans;
	}

	segment_tree(int n, vector<ll> &oarr) : arr(oarr), isum(n << 2, 0), imax(n << 2, 0)
	{
                build(1, n, 1);
	}
};

int main()
{
	int n, m;
	cin >> n;
	vector<long long> arr(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
        cin >> m;
        segment_tree sgt(n, arr);

        for(int i = 0, op, l , r; i < m; i++){
                cin >> op >> l >> r;
                if(l > r){
                        swap(l, r);
                }

                if(op == 1){
                        cout << sgt.query(l, r, 1, n, 1) << endl;;
                }else{
                        sgt.range_sqrt(l, r, 1, n, 1);
                }
        }

        return 0;
}